import { BaseItemNormal } from "../../common/item/BaseItemNormal";
import { ItemData } from "../../../resource/info/ItemData";
import { Vector } from "../../../../../__AS3__/vec/Vector";
type int = number;
//class MagicTowerAwardItems
    
    export  class MagicTowerAwardItems /* flash.display.Sprite */
    {
        constructor()
        {
            
            this._itemsVec = new Vector.<BaseItemNormal>();
            this.initItems();
            return;
        }

        /* internal  */initItems(): void
        {
            var loc1=null;
            var loc2=0;
            while (loc2 < this._maxLength) 
            {
                loc1 = new BaseItemNormal();
                loc1.setSize(32, 32);
                loc1.x = loc2 * 41;
                this._itemsVec.push(loc1);
                ++loc2;
            }
            return;
        }

        public setAwardItems(arg1: Array<any>, arg2: int=4): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            while (loc3 < arg2) 
            {
                loc1 = this._itemsVec[loc3];
                if (loc3 < arg1.length) 
                {
                    loc2 = arg1[loc3] as ItemData;
                    if (!loc1.itemData || !(loc1.itemData.itemCode == loc2.itemCode)) 
                    {
                        loc1.itemData = loc2;
                    }
                    if (!loc1.parent) 
                    {
                        this.addChild(loc1);
                    }
                }
                else 
                {
                    if (loc1.itemData) 
                    {
                        loc1.itemData = null;
                    }
                    if (loc1.parent) 
                    {
                        loc1.parent.removeChild(loc1);
                    }
                }
                ++loc3;
            }
            return;
        }

        public clearItems(): void
        {
            var loc1=null;
            var loc2=0;
            var loc3=this._itemsVec;
            for(loc1 of loc3) 
            {
                loc1.itemData = null;
                if (!loc1.parent) 
                {
                    continue;
                }
                loc1.parent.removeChild(loc1);
            }
            return;
        }

        /* internal */ /* var */_maxLength: int=5;

        /* internal */ /* var */_itemsVec: Vector.<BaseItemNormal>;
    }
